package searchPath
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.utils.*;
	
	[SWF(width = 950, height =950, frameRate = 12)]
	
	public class Map extends Sprite
	{
		//====================================
		//	Member Variables
		//====================================
		private var m_player : MapTile;
		private var m_map : Array;
		
		private var m_mapW : int =100;
		private var m_mapH : int =50;
		
		private var m_mapX : int = 10;
		private var m_mapY : int = 10;
		
		var data:Array=[]
		
		var mapPath:MapPath
		
		var players:Array=[]
			
		var mtiles:Array=[]
			
		//====================================
		//	Constructor
		//====================================
		public function Map()
		{
			var mcol=m_mapW+int(m_mapH/2)
			var mrow=m_mapW+int((m_mapH-1)/2)
				
			for (var ii:int = 0; ii <mcol; ii++ ) {
				
				data[ii]=[]
				
				for (var jj:int = 0; jj < mrow; jj++) {
					
					var item:MapPoint=new MapPoint(0,ii,jj)
						
					data[ii][jj]=item
						
				}
				
				
			}

			mapPath=new MapPath(data,mcol,mrow)
				
			getData()
				
		}
		
		private function getData(){
			
			var maps:Array=[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
				[1,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,1,0,1],
				[1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,1,0,1,1],
				[1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1],
				[1,0,0,0,0,0,0,0,1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0,0,1,1,0,1,0,0,0,0,1,0,0,0,0,0,1],
				[1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,1],
				[1,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1],
				[1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1],
				[1,0,0,0,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
				[1,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
				[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
			]
				
				//trace(maps.length)
		
			for (var i:int = 0; i <m_mapW; i++ ) {
				
				mtiles[i]=[]

				for (var j:int = 0; j < m_mapH; j++) {
					
					var m_player:MapTile
					
					if(i==0||j==0||i==m_mapW-1||j==m_mapH-1){
						
						m_player = new MapTile(0xFFcc00,m_mapX,m_mapY);
						
						var p:Point=StaggeredToDiamond(m_mapW,i,j)
						
						data[p.x][p.y].k=1
						
					}else if(maps[i][j]==1){

						m_player = new MapTile(0xFFcc00,m_mapX,m_mapY);
						
						var p:Point=StaggeredToDiamond(m_mapW,i,j)
						
						data[p.x][p.y].k=1
						
					}else{
						
						m_player = new MapTile(0xFF0000,m_mapX,m_mapY);

					}
					
					m_player.column=i
					m_player.row=j
					
					mtiles[i][j]=m_player
					
					addChild(m_player);
					
					if(j%2==0){
						
						m_player.x = m_mapX*i
						
					}else{
						
						m_player.x = m_mapX*i+m_mapX/2
						
					}
					
					m_player.y = m_mapY/2*j
					
					m_player.addEventListener(MouseEvent.CLICK, clickHandle);
					
				}
				
			}

		}
		
		public function StaggeredTilePos(w:Number,h:Number,i:Number,j:Number):Point{
		
		    var x:Number,y:Number
			
			if(j%2==0){
				
				x = w*i
				
			}else{
				
				x = w*i+w/2
				
			}
			
			y = h/2*j
				
			return new Point(x,y)
		
		
		}

		public function StaggeredToDiamond(rowCount:int,tileColumn:int,tileRow:int):Point{
			
			var column:int=int((tileRow+1)/2)+tileColumn
			var row:int=rowCount-1-tileColumn+int(tileRow/2)
			
			return new Point(column,row)
		}
		
		public function DiamondToStaggered(rowCount:int,tileColumn:int,tileRow:int):Point{
			
			var row:int=tileColumn+tileRow-rowCount+1
			var column:int=tileColumn-int((row+1)/2)
			
			return new Point(column,row)
		}
		
		
		private function getPoint(p_x : Number, p_y : Number) : Point
		{
			p_x = Math.floor((p_x - this.m_mapX) / 10);
			p_y = Math.floor((p_y - this.m_mapY) / 10);
			return new Point(p_x, p_y);
		}


		private function clickHandle(event : MouseEvent) : void
		{
			
			var  playerPoint: Point = StaggeredToDiamond(m_mapW,2,2)
			
			var  findPiont: Point = StaggeredToDiamond(m_mapW,event.target.column,event.target.row)
				
			////trace(playerPoint,findPiont)
			
			var timer:Number=getTimer()
			
			var paths:Array=mapPath.search(playerPoint.x,playerPoint.y,findPiont.x,findPiont.y)
			
			//trace(getTimer()-timer)
			
			////trace(paths)
			
		//	return;
			
			if(paths==null){return;}
			
		    var initP:MapPoint
			
			var dpaths:Array=[]
			
			for(var i=0;i<paths.length;i++){
				
				var mp:MapPoint=paths[i] as MapPoint
					
				var pp:Point=DiamondToStaggered(m_mapW,mp.x,mp.y)
				
				////trace(pp)
				
				mtiles[pp.x][pp.y].redraw(0xCCCCCC,m_mapX, m_mapY)
					
				if(initP==null){
					
					initP=mp
					
					var pp:Point=DiamondToStaggered(m_mapW,mp.x,mp.y)

					dpaths.push(pp)
				
				}else if(initP.y==mp.y||initP.x==mp.x){
				

				}else{
					
					var pp:Point=DiamondToStaggered(m_mapW,paths[i-1].x,paths[i-1].y)
					
					dpaths.push(pp)
						

					var pp:Point=DiamondToStaggered(m_mapW,mp.x,mp.y)
					
					dpaths.push(pp)
						
					initP=mp
				
				}
				

			}
			
			var pt:Point
			
			for(var p=0;p<dpaths.length;p++){
			
				var pp:Point=dpaths[p]
					
				if(pt==null){
					pt=pp
					
					mtiles[pp.x][pp.y].redraw(0xCCffff,m_mapX, m_mapY)
				
				}else if(pp.y==pt.y||pp.x==pt.x){
				
				}else{
					
					mtiles[dpaths[p-1].x][dpaths[p-1].y].redraw(0xCCffff,m_mapX, m_mapY)
						
					
				
					mtiles[pp.x][pp.y].redraw(0xCCffff,m_mapX, m_mapY)
						
					pt=pp
				
				}
				
				
					
				mtiles[dpaths[dpaths.length-1].x][dpaths[dpaths.length-1].y].redraw(0xCCffff,m_mapX, m_mapY)
			
			}
			
			
			if (paths != null&&paths.length>0 )
			{
				//trace("路径已找到，正在移动");
				//this.addEventListener(Event.ENTER_FRAME, enterframeHandle);
			} else
			{
				//trace("无法到达");
			}
		}
		
	}
}